﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Markup;
using System.Xml;
using System.Windows;
using System.Xml.Serialization;

namespace editor
{
    public class Save
    {


        //[XmlElement(Type =typeof (life_t))]
       // public life_t L_T=new life_t();
        public List <strelca>  List_strelca = new List<strelca>();
        public List<Liner> List_liner = new List<Liner>();
        public List<Textboxs> List_textbox = new List<Textboxs>();
        public List<life_t> List_L_T = new List<life_t>();
        
        
        public void save_all(string name_File)
        {
          
            // Insert code to set properties and fields of the object.
            XmlSerializer mySerializer = new
            XmlSerializer(typeof(Save));
            // To write to a file, create a StreamWriter object.
            StreamWriter myWriter = new StreamWriter(name_File);
            mySerializer.Serialize(myWriter, this);
            myWriter.Close();


            //FileStream fs = new FileStream(name_File, FileMode.Create);
            //XamlWriter.Save(this, fs);
            //fs.Close();
        }
        public void load_all(string name_File)
        {
                 XmlSerializer mySerializer = 
        new XmlSerializer(typeof(Save));
        // To read the file, create a FileStream.
        FileStream myFileStream =
        new FileStream(name_File, FileMode.Open);
        // Call the Deserialize method and cast to the object type.
        Save x = (Save)mySerializer.Deserialize(myFileStream);
        this.List_L_T = x.List_L_T;
        this.List_strelca = x.List_strelca;
        this.List_textbox = x.List_textbox;
        this.List_liner = x.List_liner;

        myFileStream.Close();
           //  FileStream fs = new FileStream(  name_File, FileMode.Open, FileAccess.Read);
           // XmlReader xmlReader = XmlReader.Create(fs);

           
           //// Canvas l_t = XamlReader.Load(xmlReader) as Canvas;
           // Save sd = (Save)XamlReader.Load(xmlReader) ;
           // fs.Close();   
        }

     
           
        


      

    }
    public class life_t
    {
          //[XmlElement(DataType = "string",
  // ElementName = "Text")]
       public List<Rectan> rect_List = new List<Rectan>();
        public string text;
   //       [XmlElement(DataType = "double",
   //ElementName = "Y")]
        public double Line_Y;
        public double set_left;
        public double Set_top;

        public void save_life_t(string tE, Double Y)
        {
            text = tE;
            Line_Y = Y;

        }
    }
    public class Rectan // параметра события (квадратик)
    {
       public double Set_top, Set_left, Hight;
      
    }
    public class strelca // параметры стрелки
    {
        //номер элемента в коллекции которому принадлежит начало стрелки
        public int begin_el_n_FC;       //главный канвас
        public int begin_el_n_TC;       //зависимый канвас
        //номер элемента в коллекции которому принадлежит конец стрелки
        public int end_el_n_FC;
        public int end_ei_n_TC;
        
        // координаты
        public double X1, X2, Y12;


    }
    public class Textboxs  // параметры коментария
    {
        public string Texts;
        public double Set_top, Set_left;
    }
    public class Liner // параметрвы линии
    {
        public double X1, X2, Y1, Y2;
    }
}
